home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-08-10 | 4.2 KB | 188 lines | [TEXT/TPAS] |
- {Some Pascal Routines for dealing with regions}
- {Copyright 1987 by Stephen Dubin, V.M.D., Ph.D.}
- {Drexel University, Philadelphia PA 19104}
-
-
- {###############################################################################}
- {# #}
- {# Contour procedure #}
- {# #}
- {###############################################################################}
-
- procedure Contour;
- var
- p1 : Point;
- p2 : Point;
- OldTick : Longint;
-
- begin
-
- Wipe;
- TotalRegion := NewRgn;
- OldTick := TickCount;
- Repeat
- GetMouse(p1);
- MoveTo(p1.h,p1.v);
- p2 := p1;
- Until Button = True;
-
- OpenRgn;
- ShowPen;
- PenMode(patXor);
-
- Repeat
- GetMouse(p2);
- Repeat Until (OldTick <> TickCount);
- LineTo(p2.h,p2.v);
- Until Button <> True;
-
- Repeat Until (OldTick <> TickCount);
- LineTo(p1.h,p1.v);
- PenNormal;
- HidePen;
- CloseRgn(TotalRegion);
- InvertRgn(TotalRegion);
-
-
- end;
-
-
- {###############################################################################}
- {# #}
- {# FreeBox procedure #}
- {# #}
- {###############################################################################}
-
- procedure FreeBox;
- var
- p1 : Point;
- p2 : Point;
- p3 : Point;
- OldTick : Longint;
- MyRect : Rect;
-
- begin
- Wipe;
- TotalRegion := NewRgn;
- OldTick := TickCount;
- PenPat(gray);
- PenMode(patXor);
-
- Repeat
- GetMouse(p1);
- p2 := p1;
- Until Button = True;
-
- OpenRgn;
- ShowPen;
- PenMode(patXor);
-
- Repeat
- Pt2Rect(p1,p2,MyRect);
- Repeat Until (OldTick <> TickCount);
- FrameRect(MyRect);
-
- Repeat
- GetMouse(p3);
- Until EqualPt(p2,p3) <> True;
-
- Repeat Until (OldTick <> TickCount);
- FrameRect(MyRect);
- p2 := p3;
-
- Until Button <> True;
-
- Pennormal;
- HidePen;
- PenPat(black);
- FrameRect(MyRect);
- CloseRgn(TotalRegion);
- InvertRgn(TotalRegion);
-
-
- end;
-
-
- {###############################################################################}
- {# #}
- {# CountPix function #}
- {# #}
- {###############################################################################}
-
- function CountPix(theRegion : RgnHandle): LongInt;
- var
- pt : Point;
- rgn : Region;
- temp : LongInt;
-
- begin
- temp := 0;
- rgn := theRegion^^;
- for pt.h := rgn.rgnBBox.left to rgn.rgnBBox.right do
- begin
- for pt.v := rgn.rgnBBox.top to rgn.rgnBBox.bottom do
- if PtInRgn( pt, TheRegion) then temp := temp + 1;
- end;
- CountPix := temp;
- end;
-
-
-
-
- {###############################################################################}
- {# #}
- {# Data procedure #}
- {# #}
- {###############################################################################}
-
- procedure Data;
- var
- rgn : Region;
- rgnpntr : Ptr;
- size : Integer;
- halfsize : Integer;
- thebuf : BUF;
- bfpntr : Ptr;
- myString : Str255;
- i : Integer;
- x : Integer;
- y : Integer;
-
- begin
- Wipe;
- TextSize(9);
- TextFont(Monaco);
- rgn := totalRegion^^;
- rgnpntr := ptr(totalRegion^);
- size := rgn.rgnSize;
- if size > 800 then size:= 800;
- bfpntr := ptr(@thebuf);
- BlockMove(rgnpntr,bfpntr,size);
- MoveTo(10,10);
- DrawString('Here are the first 400 words of the region data. (FLAG = 32767)');
- x := 10;
- y := 20;
- for i := 1 to (size div 2) do
- begin
- MoveTo(x,y);
- NumToString(theBuf[i],myString);
- if theBuf[i] < 32766 then
- begin
- if theBuf[i] <10 then DrawString(' ');
- if theBuf[i] <100 then DrawString(' ');
- if theBuf[i] < 1000 then DrawString(' ');
- if theBuf[i] < 10000 then DrawString(' ');
- DrawString(MyString);
- end;
- if theBuf[i] > 32766 then DrawString(' FLAG');
- x := x + 30;
- if (i mod 16) = 0 then
- begin
- x := 10;
- y := y+10;
- end;
- end;
-
- end;
-
-